﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp7
{
    interface getArea
    {
        double getArea();
    }
    interface legal
    {
        bool legal();
    }
    abstract class Shape : getArea, legal
    {
        public abstract double getArea();
        public abstract bool legal();
    }
    class Triangle: Shape
    {
        private double a;
        private double b;
        private double c;
        public Triangle(double a,double b,double c)
        {
            this.a = a;
            this.b = b;
            this.c = c;
        }
        public override double getArea()
        {
            double s = (a + b + c) / 2;
            return Math.Sqrt(s * (s - a) * (s - b) * (s - c));
        }
        public override bool legal()
        {
            return a + b > c & a + c > b & b + c > a;
        }
    }
    class Rectangle: Shape
    {
        private double width;
        private double hight;
        public Rectangle(double x = 0, double y = 0)
        {
            width = x;
            hight = y;
        }
        public override double getArea()
        {
            return width * hight;
        }
        public override bool legal()
        {
            return width > 0 & hight > 0;
        }
    }
    class Square : Shape
    {
        private double side;
        public Square(double a)
        {
            side = a;
        }
        public override double getArea()
        {
            return side * side;
        }
        public override bool legal()
        {
            return side > 0;
        }
    }
    class ShapeFactory
    {
        public Shape GetShape(double x)
        {
            return new Square(x);
        }
        public Shape GetShape(double x,double y)
        {
            return new Rectangle(x,y);
        }
        public Shape GetShape(double x,double y,double z)
        {
            return new Triangle(x,y,z);
        }
    }
    internal class Program
    {
        static void Main(string[] args)
        {
            double addofArea = 0;
            for (int i=0;i<10;i++)
            {
                double[] x = new double[3];
                int j = 0;
                while (true)
                {
                    string a = Console.ReadLine();
                    if (a == "")
                        break;
                    else
                    {
                        x[j] = double.Parse(a);
                        j++;
                    }
                }
                addofArea += GetArea(x);
            }
            Console.WriteLine("图形面积和为：" + addofArea);
        }
        static public double GetArea(double[]x)
        {
            ShapeFactory shapeFactory = new ShapeFactory();
            Shape newOne = shapeFactory.GetShape(x[0], x[1], x[2]);
            if (newOne.legal())
                return newOne.getArea();
            newOne= shapeFactory.GetShape(x[0], x[1]);
            if (newOne.legal())
                return newOne.getArea();
            newOne = shapeFactory.GetShape(x[0]);
            if (newOne.legal())
                return newOne.getArea();
            else
                return 0;
        }
    }
}
